//
//  PinViewController.swift
//  XMYouPin
//
//  Created by 王宗成 on 2019/7/2.
//  Copyright © 2019 王宗成. All rights reserved.
//

import UIKit


class PinViewController: UIViewController {
    
    lazy var viewModel: PinViewModel = {
        
        let model = PinViewModel()
        model.delegate = self
        return model
    }()
    
    lazy var tableView:UITableView = {
        
        let tab:UITableView = UITableView(frame: CGRect.init(x: 0, y: 0, width: kScreenH, height: kScreenH), style: .grouped)
        tab.separatorStyle = UITableViewCell.SeparatorStyle.none
        tab.register(PinBannerTableViewCell.self, forCellReuseIdentifier: PinBannerTableViewCell.identifier())
        
        tab.register(HomeTodayActivityTableViewCell.self, forCellReuseIdentifier: HomeTodayActivityTableViewCell.identifier())
        
        tab.register(PinPinWeiTableViewCell.self, forCellReuseIdentifier: PinPinWeiTableViewCell.identifier())
        
        tab.register(PinDujiaTableViewCell.self, forCellReuseIdentifier: PinDujiaTableViewCell.identifier())
        
        tab.register(WZC_TableViewHeaderFooterView.self, forHeaderFooterViewReuseIdentifier: WZC_TableViewHeaderFooterView.identifier())
        
        
        tab.register(WZC_TableViewCell.self, forCellReuseIdentifier: WZC_TableViewCell.identifier())
        return tab
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.title = "品味"
        configTableView()
        // Do any additional setup after loading the view.
    }
    
    
    /*
     // MARK: - Navigation
     
     // In a storyboard-based application, you will often want to do a little preparation before navigation
     override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
     // Get the new view controller using segue.destination.
     // Pass the selected object to the new view controller.
     }
     */
    
}

extension PinViewController{
    
    func configTableView() -> Void {
        
        self.view.addSubview(tableView)
        self.tableView.delegate = self.viewModel
        self.tableView.dataSource = self.viewModel
        self.tableView.backgroundColor = .white
//        if #available(iOS 11.0,*) {
//            
//            self.tableView.contentInsetAdjustmentBehavior = .never
//        }
        
        tableView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
    }
}
